//
//  CSHApiClient+Ext.m
//  mompharmacy
//
//  Created by chaizhiyong on 15/5/12.
//  Copyright (c) 2015年 chaizhiyong. All rights reserved.
#import "CSHApiClient+Ext.h"
#import "LKDHud.h"

@implementation CSHApiClient (Ext)
+ (void)requestWithUrlString:(NSString *)urlString params:(NSMutableDictionary *)params httpMethod:(NSString*)httpMethod didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail
{
   
    NSLog(@"参数=======%@",params);
    NSLog(@"地址=======%@",urlString);
    NSAssert(urlString!=nil, @"the url path can't be null");
    NSDictionary *headers = [NSDictionary dictionaryWithObjectsAndKeys:@"application/x-www-form-urlencoded;charset=utf-8;", @"Content-Type", @"2",@"_p",[[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey],@"_v",[[[UIDevice currentDevice] macaddressOrIDFA] stringByReplacingOccurrencesOfString:@":" withString:@""],@"_m",nil];
    
    MKNetworkOperation *operation = [CSHApiClient requestWithUrlString:urlString headers:headers params: params httpMethod:httpMethod];
    
    //[operation addData:imageData forKey:@"file_name" mimeType:@"image/png" fileName:@"image.png"];  //图片
    
    [operation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSLog(@"responseString=%@", completedOperation.responseString);
        KXJson *result = [KXJson jsonWithJsonString:completedOperation.responseString];
        if (finish) {
            finish(result, urlString);
        }
        
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        
        if (fail) {
            fail(error, urlString);
        }
    }];
    [[CSHApiClient engine] enqueueOperation:operation];
}

+ (void)requestWithPath:(NSString *)path params:(NSMutableDictionary *)params httpMethod:(NSString*)httpMethod didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail
{
    [[LKDHud shareHud] showLoadingView];
    NSAssert(path!=nil, @"the url path can't be null");
    NSDictionary *headers = [NSDictionary dictionaryWithObjectsAndKeys:@"application/x-www-form-urlencoded;charset=utf-8;", @"Content-Type", @"2",@"_p",[[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey],@"_v",[[[UIDevice currentDevice] macaddressOrIDFA] stringByReplacingOccurrencesOfString:@":" withString:@""],@"_m",nil];
    [params setValue:@"iphone" forKey:@"client_type"];
    [params setValue:@"1" forKey:@"v"];
    [params setValue:@"1" forKey:@"is_debug"];
    [params setValue:@"yskhudqweha" forKey:@"app_key"];
    NSString *token=[[UserInfo SharedUserfo] user_token];
    if (token) {
      [params setValue:token forKey:@"user_token"];
    }
   
    QLKDLog(@"params==%@",params);
    MKNetworkOperation *operation = [CSHApiClient requestWithPath:path headers:headers params: params httpMethod:httpMethod];
    
    //[operation addData:imageData forKey:@"file_name" mimeType:@"image/png" fileName:@"image.png"];  //图片
    
    [operation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSLog(@"responseString=%@", completedOperation.responseString);
        KXJson *result = [KXJson jsonWithJsonString:completedOperation.responseString];
        [[LKDHud shareHud] hideLoadingView];
        if (finish) {
            if ([result getIntForKey:@"code"]!=200) {
                [[LKDHud shareHud] showtip:[result getStringForKey:@"message"]];
            }
            finish(result, path);
        }
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        [[LKDHud shareHud] hideLoadingView];
        [[LKDHud shareHud] showtip:@"请检查网络设置"];
        if (fail) {
            fail(error, path);
        }
    }];
    [[CSHApiClient engine] enqueueOperation:operation];
}
#pragma mark-获取验证码
+ (void)getTelVerifyCodeWithPhoneNum:(NSString *)phoneNum didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail
{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:phoneNum forKey:@"mobile"];
    [paramsDict setObject:@"passport.sendVerificationCode" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
   
}
#pragma mark-注册
+ (void)registerWithPhoneNum:(NSString *)phoneNum verification_code:(NSString*)verification_code password:(NSString*)password didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:phoneNum forKey:@"mobile"];
    [paramsDict setObject:verification_code forKey:@"verification_code"];
    [paramsDict setObject:password forKey:@"password"];
    [paramsDict setObject:@"passport.register" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-登录
+(void)loginWithMobile:(NSString*)mobile password:(NSString*)password didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:mobile forKey:@"account"];
    [paramsDict setObject:@"passport.login" forKey:@"method"];
    [paramsDict setObject:password forKey:@"password"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

    
}
#pragma mark-验证短信验证码
+(void)checkVerificationCode:(NSString*)verification_code mobile:(NSString*)mobile  didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:mobile forKey:@"mobile"];
    [paramsDict setObject:verification_code forKey:@"verification_code"];
    [paramsDict setObject:@"passport.checkVerificationCode" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
    
}
#pragma mark-重置密码
+(void)setPassword:(NSString*)password VerificationCode:(NSString*)verification_code mobile:(NSString*)mobile  didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:mobile forKey:@"mobile"];
    [paramsDict setObject:verification_code forKey:@"verification_code"];
    [paramsDict setObject:@"passport.setPassword" forKey:@"method"];
    [paramsDict setObject:password forKey:@"password"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

}
#pragma mark-获取信息
+(void)getUserInfoType:(NSString*)type didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"passport.getUserInfo" forKey:@"method"];
    [paramsDict setObject:type forKey:@"type"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

}
#pragma mark-患者评价 HTML5
+(void)getPatientJudgeDidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"passport.getPatientJudge" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-获取医师资格认证
+(void)getDoctorAccredDidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"passport.getDoctorAccred" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
    
}
#pragma mark-更新个人信息
+(void)updateInfoAccredHead_ico:(NSString*)head_ico doctor_name:(NSString*)doctor_name gender:(NSString*)gender tel:(NSString*)tel email:(NSString*)email hospital_name:(NSString*)hospital_name department:(NSString*)department job_name:(NSString*)job_name begoodat:(NSString*)begoodat card_pic_path:(NSString*)card_pic_path work_pic_path:(NSString*)work_pic_path didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"passport.update" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:head_ico key:@"head_ico"];
    [CSHApiClient setParmarDir:paramsDict value:doctor_name key:@"doctor_name"];
    [CSHApiClient setParmarDir:paramsDict value:gender key:@"gender"];
    [CSHApiClient setParmarDir:paramsDict value:tel key:@"tel"];
    [CSHApiClient setParmarDir:paramsDict value:email key:@"email"];
    [CSHApiClient setParmarDir:paramsDict value:hospital_name key:@"hospital_name"];
    [CSHApiClient setParmarDir:paramsDict value:department key:@"department"];
    [CSHApiClient setParmarDir:paramsDict value:job_name key:@"job_name"];
    [CSHApiClient setParmarDir:paramsDict value:begoodat key:@"begoodat"];
    [CSHApiClient setParmarDir:paramsDict value:card_pic_path key:@"card_pic_path"];
    [CSHApiClient setParmarDir:paramsDict value:work_pic_path key:@"work_pic_path"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-获取二维码
+(void)getQRcodeIs_examine:(NSString*)is_examine didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"passport.getQRcode" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:is_examine key:@"is_examine"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-设置加号服务
+(void)getOpenAdddidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"getOpenAdd" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-获取黑名单
+(void)setOpenAddIs_add:(int)is_add DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"passport.getBlackList" forKey:@"method"];
    [paramsDict setObject:[NSNumber numberWithInt:is_add] forKey:@"is_add"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

}
#pragma mark-获取黑名单
+(void)getBlackListDidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"passport.getBlackList" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-首页(消息数量)
+(void)getInfoNumDidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.getInfoNum" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

}
#pragma mark-添加患者
+(void)addPatientNumAppend_tag:(NSString*)append_tag Tag_ids:(NSString*)tag_ids patient_code:(NSString*)patient_code tel:(NSString*)tel DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.addPatient" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:append_tag key:@"append_tag"];
    [CSHApiClient setParmarDir:paramsDict value:tag_ids key:@"tag_ids"];
    [CSHApiClient setParmarDir:paramsDict value:patient_code key:@"patient_code"];
    [CSHApiClient setParmarDir:paramsDict value:tel key:@"tel"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
    
}
#pragma mark-加号申请列表
+(void)patientAppliListDidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.patientAppliList" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}

#pragma mark-患者申请详情（就诊记录用html5 实现）
+(void)patientAppliDetailPatient_code:(NSString*)patient_code DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.patientAppliDetail" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}

#pragma mark-我申请项目审核通知列表
+(void)myToAppliProjNoticeListDidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.myToAppliProjNoticeList" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

}
#pragma mark-向我申请项目列表
+(void)toMyAppliProjListItemApplyModel:(itemApplyModel)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.toMyAppliProjList" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:^(KXJson *json, NSString *path) {
        ItemApplyModel *model=[[ItemApplyModel alloc] initWithDictionary:json.json];
        finish(model,path);
        
    } didFailLoaded:^(NSError *error, NSString *path) {
        fail(error,path);
    }];

}

#pragma mark-向我申请项目详情
+(void)toMyAppliProjDetailApply_doc_id:(NSString*)apply_doc_id DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.toMyAppliProjDetail" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:apply_doc_id key:@"apply_doc_id"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

    
}
#pragma mark-向我申请项目通过
+(void)toMyAppliProjPassSolution_id:(NSString*)solution_id apply_doc_id:(NSString*)apply_doc_id DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.toMyAppliProjPass" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:solution_id key:@"solution_id"];
    [CSHApiClient setParmarDir:paramsDict value:apply_doc_id key:@"apply_doc_id"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-搜索标签
+(void)searchTagDidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail;{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.selectTag" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-编辑标签
+(void)editTagTag_id:(NSString*)tag_id DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.editTag" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:tag_id key:@"tag_id"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-删除标签
+(void)deleteTagTag_id:(NSString*)tag_id DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.deleteTag" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:tag_id key:@"tag_id"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-编辑标签保存
+(void)editTagSaveTag_id:(NSString*)tag_id tag_text:(NSString*)tag_text DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Homepage.editTagSave" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:tag_id key:@"tag_id"];
    [CSHApiClient setParmarDir:paramsDict value:tag_text key:@"tag_text"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-获取患者列表
+(void)getPatientListKeyword:(NSString*)keyword date:(NSString*)date sex:(NSString*)sex age:(NSString*)age disease:(NSString*)disease solution:(NSString*)solution didFinishLoaded:(patientListModelDataModel)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"patient.getPatientList" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:keyword key:@"keyword"];
   [ CSHApiClient setParmarDir:paramsDict value:date key:@"date"];
    [CSHApiClient setParmarDir:paramsDict value:sex key:@"sex"];
    [CSHApiClient setParmarDir:paramsDict value:age key:@"age"];
    [CSHApiClient setParmarDir:paramsDict value:disease key:@"disease"];
    [CSHApiClient setParmarDir:paramsDict value:solution key:@"solution"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:^(KXJson *json, NSString *path) {
            LKDPatientListModel *model=[[LKDPatientListModel alloc] initWithDictionary:json.json];
            finish(model,path);
    
        } didFailLoaded:^(NSError *error, NSString *path) {
            fail(error,path);
        }];
    
}
#pragma mark-获取患者详情
+(void)getPatientDetailPatient_code:(NSString*)patient_code info_type:(NSString*)info_type DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"patient.getPatientDetail" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:patient_code key:@"patient_code"];
    [CSHApiClient setParmarDir:paramsDict value:info_type key:@"info_type"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

    
}
#pragma mark-获取就诊记录
+(void)getMedicalRecordPatient_code:(NSString*)patient_code didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"patient.getMedicalRecord" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:patient_code key:@"patient_code"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

    
}
#pragma mark-设置黑名单
+(void)setToBlackListPatient_code:(NSString*)patient_code didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"patient.setToBlackList" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:patient_code key:@"patient_code"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
 
}
#pragma mark-获取已选标签
+(void)getSelectedTagPatient_code:(NSString*)patient_code didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"patient.getSelectedTag" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:patient_code key:@"patient_code"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];

}
#pragma mark-编辑患者标签
+(void)setTagPatient_code:(NSString*)patient_code tag_ids:(NSString*)tag_ids special_tag:(NSString*)special_tag didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"patient.setTag" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:patient_code key:@"patient_code"];
    [CSHApiClient setParmarDir:paramsDict value:tag_ids key:@"tag_ids"];
    [CSHApiClient setParmarDir:paramsDict value:special_tag key:@"special_tag"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-出诊设置
+(void)ourcallsetDidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Schedule.ourcallset" forKey:@"method"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-出诊设置确定
+(void)outcallConfirmReturn_set_outcall:(NSString*)return_set_outcall DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Schedule.outcallConfirm" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:return_set_outcall key:@"return_set_outcall"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-日程表展示
+(void)displayRiliOpen_date:(NSString*)open_date DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Schedule.schedule" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:open_date key:@"open_date"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-一天的日程表
+(void)scheduleDayOpen_date:(NSString*)open_date DidFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Schedule.scheduleDay" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:open_date key:@"open_date"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-一天的日程表加人保存
+(void)ourcallPeopleNumOpen_date:(NSString*)open_date open_time:(NSString*)open_time open_num:(NSString*)open_num didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"Schedule.ourcallPeopleNum" forKey:@"method"];
    [CSHApiClient setParmarDir:paramsDict value:open_date key:@"open_date"];
    [CSHApiClient setParmarDir:paramsDict value:open_date key:@"open_time"];
    [CSHApiClient setParmarDir:paramsDict value:open_date key:@"open_num"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"POST" didFinishLoaded:finish didFailLoaded:fail];
}
#pragma mark-设置传参
+(void)setParmarDir:(NSMutableDictionary*)paramsDict value:(NSString*)value key:(NSString*)key{
    if (value) {
        [paramsDict setObject:value forKey:key];
    }
   
}

















#pragma mark-token登录
+(void)loginWithToken:(NSString*)token didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:@"user" forKey:@"api"];
    [paramsDict setObject:@"login" forKey:@"action"];
    [paramsDict setObject:token forKey:@"token"];
    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
}








//#pragma mark-扫一扫获取商店的信息
//+(void)getShopInfoFromScanContent:(NSString*)content didFinishLoaded:(shopInfoDataModel)finish didFailLoaded:(didFailLoaded)fail{
//    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
//    [paramsDict setObject:@"user" forKey:@"api"];
//    [paramsDict setObject:@"scan" forKey:@"action"];
//    [paramsDict setObject:content forKey:@"content"];
//    [paramsDict setObject:@"" forKey:@"token"];
//    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"GET" didFinishLoaded:^(KXJson *json, NSString *path) {
//        CTShopInfoModel *model=[[CTShopInfoModel alloc] initWithDictionary:json.json];
//        finish(model,path);
//        
//    } didFailLoaded:^(NSError *error, NSString *path) {
//        fail(error,path);
//    }];
//}
//#pragma mark-扫一扫获取卡的信息
//+(void)getCardInfoFromScanContent:(NSString*)content didFinishLoaded:(cardInfoDataModel)finish didFailLoaded:(didFailLoaded)fail{
//    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
//    [paramsDict setObject:@"user" forKey:@"api"];
//    [paramsDict setObject:@"scan" forKey:@"action"];
//    [paramsDict setObject:content forKey:@"content"];
//    [paramsDict setObject:@"" forKey:@"token"];
//    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"GET" didFinishLoaded:^(KXJson *json, NSString *path) {
//        CTCardInfoModel *model=[[CTCardInfoModel alloc] initWithDictionary:json.json];
//        finish(model,path);
//        
//    } didFailLoaded:^(NSError *error, NSString *path) {
//        fail(error,path);
//    }];
//
//}
//
//#pragma mark-常用会员卡(已经领取)
//+(void)getCardsHaveDrawedLongitude:(NSString*)longitude latitude:(NSString*)latitude didFinishLoaded:(cardsListDataModel)finish didFailLoaded:(didFailLoaded)fail{
//    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
//    [paramsDict setObject:@"nearbySearch" forKey:@"api"];
//    [paramsDict setObject:@"cnou" forKey:@"action"];
//    [paramsDict setObject:longitude forKey:@"longitude"];
//    [paramsDict setObject:latitude forKey:@"latitude"];
//    [paramsDict setObject:@"" forKey:@"token"];
//    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"GET" didFinishLoaded:^(KXJson *json, NSString *path) {
//        CTCardsListModel *model=[[CTCardsListModel alloc] initWithDictionary:json.json];
//        finish(model,path);
//        
//    } didFailLoaded:^(NSError *error, NSString *path) {
//        fail(error,path);
//    }];
//
//}
//
//#pragma mark-附近会员卡(未领取)
//+(void)getCardsNoDrawedLongitude:(NSString*)longitude latitude:(NSString*)latitude didFinishLoaded:(cardsListDataModel)finish didFailLoaded:(didFailLoaded)fail{
//    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
//    [paramsDict setObject:@"nearbySearch" forKey:@"api"];
//    [paramsDict setObject:@"reco" forKey:@"action"];
//    [paramsDict setObject:longitude forKey:@"longitude"];
//    [paramsDict setObject:latitude forKey:@"latitude"];
//    [paramsDict setObject:@"" forKey:@"token"];
//    [CSHApiClient requestWithPath:kAPI_path params:paramsDict httpMethod:@"GET" didFinishLoaded:^(KXJson *json, NSString *path) {
//        CTCardsListModel *model=[[CTCardsListModel alloc] initWithDictionary:json.json];
//        finish(model,path);
//        
//    } didFailLoaded:^(NSError *error, NSString *path) {
//        fail(error,path);
//    }];
//
//}
//













/**
+ (void)detailCollection:(NSString*)dId type:(NSString*)type detailType:(NSString*)detailType didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:dId forKey:@"a_id"];
    [paramsDict setObject:type forKey:@"type"];
    [paramsDict setObject:[CSHUser sharedInstance].userid forKey:@"s_id"];
    
    if([@"1" isEqualToString:detailType]){
      [CSHApiClient requestWithPath:kAPI_article_collect params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
    }else{
      [CSHApiClient requestWithPath:kAPI_video_collect params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
    }
}
+ (void)detailOpinion:(NSString*)dId type:(NSString*)type detailType:(NSString*)detailType didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:dId forKey:@"a_id"];
    [paramsDict setObject:type forKey:@"type"];
    [paramsDict setObject:type forKey:@"type"];
    [paramsDict setObject:[CSHUser sharedInstance].userid forKey:@"s_id"];
    if([@"1" isEqualToString:detailType]){
        [CSHApiClient requestWithPath:kAPI_article_praise params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
    }else{
        [CSHApiClient requestWithPath:kAPI_video_praise params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
    }
    
}
+ (void)userLoginWithPhoneNum:(NSString *)phoneNum passwd:(NSString *)pwd didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
 
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:phoneNum forKey:@"telephone"];
    [paramsDict setObject:pwd forKey:@"password"];
    [CSHApiClient requestWithPath:kAPI_login params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
}

+ (void)updatePasswordWithOldPwd:(NSString *)oldPwd newPwd:(NSString *)newPwd didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    if (!KCNSSTRING_ISEMPTY([CSHUser sharedInstance].username)) {
        [paramsDict setObject:[CSHUser sharedInstance].username forKey:@"username"];
    }
    [paramsDict setObject:oldPwd forKey:@"oldpassword"];
    [paramsDict setObject:newPwd forKey:@"newpassword"];
    [CSHApiClient requestWithPath:kAPI_setting_changepass params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
}

+ (void)checkPasswordWithPhoneNum:(NSString *)phoneNum  verifyCode:(NSString *)verifyCode didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:phoneNum forKey:@"telephone"];
    [paramsDict setObject:verifyCode forKey:@"captcha"];
    [CSHApiClient requestWithPath:kAPI_resetPass_telephone params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
}

+ (void)updateVerifyCodeWithPhoneNum:(NSString *)phoneNum verifyCode:(NSString *)verifyCode didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    if (!KCNSSTRING_ISEMPTY([CSHUser sharedInstance].username)) {
        [paramsDict setObject:[CSHUser sharedInstance].username forKey:@"username"];
    }
    [paramsDict setObject:phoneNum forKey:@"telephone"];
    [paramsDict setObject:verifyCode forKey:@"captcha"];
    [CSHApiClient requestWithPath:kAPI_changeTele_submitOldTele params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
}

+ (void)inputPasswordWithPhoneNum:(NSString*)phoneNum newPwd:(NSString *)newPwd didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    if (!KCNSSTRING_ISEMPTY([CSHUser sharedInstance].username)) {
        [paramsDict setObject:[CSHUser sharedInstance].username forKey:@"username"];
    }
    if (!KCNSSTRING_ISEMPTY(phoneNum)) {
          [paramsDict setObject:phoneNum forKey:@"telephone"];
    }
    [paramsDict setObject:newPwd forKey:@"password"];
    [CSHApiClient requestWithPath:kAPI_resetPass_password params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
}

+ (void)changeBindPhoneWithNewPhoneNum:(NSString*)phoneNum verifyCode:(NSString *)verifyCode didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    if (!KCNSSTRING_ISEMPTY([CSHUser sharedInstance].username)) {
        [paramsDict setObject:[CSHUser sharedInstance].username forKey:@"username"];
    }
    [paramsDict setObject:phoneNum forKey:@"telephone"];
    [paramsDict setObject:verifyCode forKey:@"captcha"];
    [CSHApiClient requestWithPath:kAPI_changeTele_submitNewTele params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
}

+ (void)getUserInfoWithUserName:(NSString*)userName didFinishLoaded:(userInfoFinishLoaded)finish didFailLoaded:(didFailLoaded)fail
{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:userName forKey:@"username"];
    [CSHApiClient requestWithPath:kAPI_user_userInfo params:paramsDict httpMethod:@"GET" didFinishLoaded:^(KXJson *json, NSString *path){
        CSHUserInfoModel *model = [[CSHUserInfoModel alloc]initWithDictionary:json.json];
        finish(model,path);
        
    } didFailLoaded:fail];
}

//更新年龄
+ (void)updateUserInfoWithAge:(NSString*)age didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
     NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    if (!KCNSSTRING_ISEMPTY([CSHUser sharedInstance].username)) {
        [paramsDict setObject:[CSHUser sharedInstance].username forKey:@"username"];
    }
    if (!KCNSSTRING_ISEMPTY(age)) {
        [paramsDict setObject:age forKey:@"age"];
    }
    
    [CSHApiClient requestWithPath:kAPI_user_perfectInfo_age params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];

}
//更新性别
+ (void)updateUserInfoWithSex:(NSString *)sex didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    if (!KCNSSTRING_ISEMPTY([CSHUser sharedInstance].username)) {
        [paramsDict setObject:[CSHUser sharedInstance].username forKey:@"username"];
    }
    
    if (!KCNSSTRING_ISEMPTY(sex)) {
        [paramsDict setObject:sex forKey:@"sex"];
    }
    [CSHApiClient requestWithPath:kAPI_user_perfectInfo_sex params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
    
}

+ (void)getHomepageType:(CSHHomepageType)columnType finish:(articleDataModel)finish didFailLoaded:(didFailLoaded)fail{
    // 本地测试
//    NSString* jsonString = [[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"articlelist" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
//    KXJson *result = [KXJson jsonWithJsonString:jsonString];
//    NSDictionary *dic = result.json;
//    ArticleDataModel* data = [[ArticleDataModel alloc] initWithDictionary:dic];
//    finish(data,nil);
//    return;
    
    [CSHApiClient requestWithPath:kAPI_homepage_dict[[NSString stringWithFormat:@"%d", columnType]] params:nil httpMethod:@"GET" didFinishLoaded:^(KXJson *json, NSString *path){
        NSDictionary *dic = json.json;
        ArticleDataModel* data = [[ArticleDataModel alloc] initWithDictionary:dic];
        finish(data,path);
    }  didFailLoaded:fail];
}

+ (void)getHomepageType:(CSHHomepageType)columnType page: (int)page finish:(articleDataModel)finish didFailLoaded:(didFailLoaded)fail{
    NSString* urlString = [NSString stringWithFormat:@"%@%@page=%d", kAPI_homepage_dict[[NSString stringWithFormat:@"%d", columnType]], columnType == EHomepageTypeVideo ? @"?" : @"&", page];
    [CSHApiClient requestWithPath: urlString params:nil httpMethod:@"GET" didFinishLoaded:^(KXJson *json, NSString *path){
        NSDictionary *dic = json.json;
        ArticleDataModel* data = [[ArticleDataModel alloc] initWithDictionary:dic];
        finish(data,path);
    }  didFailLoaded:fail];
}

+(void)getCollectionListDidFinishLoaded:(collectDataModel)finish didFailLoaded:(didFailLoaded)fail{
     NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
     [paramsDict setObject:[CSHUser sharedInstance].username forKey:@"username"];
     CSHDLog(@"收藏列表获取的参数==%@",paramsDict);
    [CSHApiClient requestWithPath:kAPI_collectionList params:paramsDict httpMethod:@"GET" didFinishLoaded:^(KXJson *json, NSString *path) {
        NSDictionary *dic = json.json;
        CSHCollectionModel *model=[[CSHCollectionModel alloc] initWithDictionary:dic];
        finish(model,path);
        
    } didFailLoaded:^(NSError *error, NSString *path) {
        fail(error,path);
    }];
    
}
+(void)deleteCollectIDs:(NSDictionary*)ids didFinishLoaded:(didFinishLoaded)finish didFailLoaded:(didFailLoaded)fail{
    NSMutableDictionary *paramsDict = [NSMutableDictionary dictionary];
    [paramsDict setObject:[CSHUser sharedInstance].username forKey:@"username"];
    [paramsDict setObject:ids[@"articleInfo"] forKey:@"articleInfo"];
    [paramsDict setObject:ids[@"videoInfo"] forKey:@"videoInfo"];
     [CSHApiClient requestWithPath:kAPI_collectiondelete params:paramsDict httpMethod:@"GET" didFinishLoaded:finish didFailLoaded:fail];
    
    
}
 **/
@end
